// 计算奖金接口
interface ISalary
{
    void Calc();
}

public class Level1Salary:ISalary
{
    public static readonly int Level = 1;

    public void Calc()
    {
        Console.WriteLine("等级1的奖金计算");
    }
}

public class Level2Salary:ISalary
{
    public static readonly int Level = 2;

    public void Calc()
    {
        Console.WriteLine("等级2的奖金计算");
    }
}

public class Level3Salary:ISalary
{
    public static readonly int Level = 3;

    public void Calc()
    {
        Console.WriteLine("等级3的奖金计算");
    }
}

public Context
{
    ISalary salaryStragegy;

    public Context(ISalary salary)
    {
        this.salaryStragegy = salary;
    }

    public void Calc()
    {
        this.salaryStragegy.Calc();
    }
}

// 消费场景
public class MainApp
{
    public static void Main()
    {
        Context context;

        context = new Context(new Level1Salary());
        context.Calc();

        context = new Context(new Level2Salary());
        context.Calc();

        context = new Context(new Level3Salary());
        context.Calc();

        // 
        foreach (var item in new List<int> {1, 2, 3})
        {
            CalcSalary(item);
        }
    }

    // 稍微改进一下
    public List<ISalary> LevelSalarys = new List<ISalary>{new Level1Salary(), new Level2Salary(), new Level3Salary()};

    public void CalcSalary(int level)
    {
        var levelSalary = LevelSalarys.Find(l=>l.Level.equals(level));
        new Context(levelSalary).Calc();
    }
}

